package com.example.administrator.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.example.administrator.myapplication.adapter.MeunAdapter;

public class MainActivity extends AppCompatActivity {
    ListView meunListView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initEvent();
    }

    private void initView() {
        String[] meunArray = new String[] {"用户列表","校园新闻"};
        meunListView = (ListView) findViewById(R.id.menu_listview);
        MeunAdapter meunAdapter = new MeunAdapter(MainActivity.this,meunArray);
        meunListView.setAdapter(meunAdapter);
    }
    private void initData() {

    }
    private void initEvent() {
        meunListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch (position){
                    case 0:
                        startActivity(new Intent(MainActivity.this,ClassmateListActivity.class));
                        break;
                    case 1:
                        break;
                }
            }
        });
    }

}
